<?php

namespace app\shop\model\product;

use app\common\model\product\Recommend as RecommendModel;

/**
 * 推荐模型
 */
class Recommend extends RecommendModel
{
    
    /**
     * 添加新记录
     */
    public function add($data)
    {
        $data['app_id'] = self::$app_id;
        return $this->save($data);
    }

    /**
     * 编辑记录
     */
    public function edit($data)
    {
      
        $data['update_time'] = time();
        return $this->save($data);
    }

    /**
     * 删除
     */
    public function remove()
    {
        // 判断是否存在
        $Count = (new RecommendList())->where('module_id','=' ,$this['id'])->where('status','=','1')->count();
        if ($Count > 0) {
            $this->error = '该推荐使用中，不允许删除';
            return false;
        }
        return $this->delete();
    }

 
}